package Model.Beans;

import java.beans.*;
import java.io.Serializable;
import Model.XML.*;

public class ClassRoom extends Object implements Serializable, XMLRequestInterface { 
    private String building = "";
    private int number = 0;
    private int id = 0;
    private XMLWriter xml;
    
    public ClassRoom() 
    {
        xml = new XMLWriter();
    }
    
    public ClassRoom(int id, String building, int number)
    {
        this.id = id;
        this.building = building;
        this.number = number;
        xml = new XMLWriter();
    }
    
    public ClassRoom(String building, int number)
    {
        this(0, building, number);
    }
    
    public String getBuilding()
    {
        return building;
    }
    
    public void setBuilding(String building)
    {
        this.building = building;
    }
    
    public int getNumber()
    {
        return number;
    }
    
    public void setNumber(int number)
    {
        this.number = number;
    }
    
    public int getId()
    {
        return id;
    }
    
    public void setId(int id)
    {
        this.id = id;
    }
    
    public String toString()
    {
        StringBuilder result = new StringBuilder();
        result.append(this.building + "-" + this.number);
        return result.toString();
    }
    
    public String toXML()
    {
        xml.Push("classroom");
        xml.Element("id", Integer.toString(this.id));
        xml.Element("building", this.building);
        xml.Element("number", Integer.toString(this.number));
        
        xml.Pop();
        return xml.GetXML();
    }
}
